-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(next): add Astro.routePattern
#11698
Conversation
🦋 Changeset detectedLatest commit: f46dc07 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
Definitely route. Component would be confusing. |
Do we have use-case for this? I'm not against it, just wondering what it's for. I'm assuming it's something Starlight would want? |
@matthewp If you check the linear ticket, Chris left a comment that explains the use case |
As Chris said, I think it would more useful to have pattern than the component, so |
FWIW the recent |
|
When I said I thought it should ne |
75550db
to
a30529a
Compare
a30529a
to
8df60cc
Compare
I actually quite like |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Astro.route
Astro.routePattern
|
It will contain the value of the route you're about to render. I can add more tests if you want.
The updated value based on the payload provided to
The updated value based on the payload provided to
Sounds good |
Astro.routePattern
Astro.route.pattern
Astro.route.pattern
Astro.routePattern
Just commenting that I will wait on the docs PR to the API reference page before reviewing the changeset here! 🙌 |
Should the route pattern have a leading slash? like to match RouteData |
@sarah11918 docs are up |
// src/pages/index.js | ||
|
||
export const GET = (ctx) => { | ||
console.log(ctx.routePattern) // it will log src/pages/index.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ematipico I know this has already merged, but according to the line in docs about index.*
showing only /
, is this code comment about what's logged correct? It also includes the file extension here.
We will proofread all the changesets before 5.0 beta release anyway, so I'm not concerned about updating this right now. but I just want to make sure I'm understanding correctly!
Changes
For Astro 5.0
Closes PLT-2339
It adds a new field to the
Astro
global calledroutePattern
.route
isRouteData.component
withoutsrcDir
andpages
:src/pages/index.astro
->index
src/pages/blog/[post].astro
->blog/[post]
Testing
I added new tests
Docs
withastro/docs#9180
/cc @withastro/maintainers-docs for feedback!